//
//  SQConfirmConfirmViewController.m
//  energy
//
//  Created by 周曼迪 on 2021/7/12.
//

#import "SQConfirmConfirmViewController.h"

#import "SQQueryModel.h"
#import "SQGetDictionariesModel.h"
#import "SQHierarchyModel.h"
#import "SQConfirmConfirmModel.h"
#import "SQShowImage.h"

#import "NSString+NCDate.h"
#import "PickerSelectView.h"
#import "HRBDateSelectView.h"
#import "SQPlayVoiceView.h"


@interface SQConfirmConfirmViewController ()<BaseTableVCInterface>

@property (strong, nonatomic) SQGetDictionariesModel *getDictionariesModel;
@property (strong, nonatomic) SQHierarchyModel *hierarchyModel;
@property (strong, nonatomic) SQQueryModel *queryModel;

@property (weak, nonatomic) IBOutlet UIView *view_confirm;
@property (weak, nonatomic) IBOutlet UIButton *btn_confirm;
@property (weak, nonatomic) IBOutlet UITextField *tf_type;//隐患类别
@property (weak, nonatomic) IBOutlet UITextField *tf_level;//隐患等级
@property (weak, nonatomic) IBOutlet UITextField *tf_rectificationType;//隐患整改类型

@property (weak, nonatomic) IBOutlet UIImageView *img_confirm;
@property (weak, nonatomic) IBOutlet UIImageView *img_invalid;
@property (weak, nonatomic) IBOutlet UITextField *tf_completionTime;//隐患整改时间

@property (weak, nonatomic) IBOutlet UITextField *tf_money;
@property (weak, nonatomic) IBOutlet UITextField *tf_prevention;//防控措施
@property (weak, nonatomic) IBOutlet UITextField *tf_system;//制度措施清单
@property (weak, nonatomic) IBOutlet UITextField *tf_rectification;//整改措施
@property (weak, nonatomic) IBOutlet UITextView *tv_note;//备注
//༥༤༽ཀབཀྲ་ཤིས་བདེ་ལེགས།

@property (weak, nonatomic) IBOutlet UIView *view_information;
@property (weak, nonatomic) IBOutlet UIButton *btn_information;

@property (weak, nonatomic) IBOutlet UITextField *tf_area;//区域
@property (weak, nonatomic) IBOutlet UITextField *tf_people;//发现人

@property (weak, nonatomic) IBOutlet UITextField *tf_class;//班组
@property (weak, nonatomic) IBOutlet UITextField *tf_department;//部门
@property (weak, nonatomic) IBOutlet UITextField *tf_company;//公司
@property (weak, nonatomic) IBOutlet UITextField *tf_assessmentTime;//评估时间
@property (weak, nonatomic) IBOutlet UITextView *tv_describe;//隐患描述

@property (weak, nonatomic) IBOutlet UIImageView *img_picOne;
@property (weak, nonatomic) IBOutlet UIImageView *img_picTwo;
@property (weak, nonatomic) IBOutlet UIImageView *img_picThree;
@property (weak, nonatomic) IBOutlet UIView *view_header;

@property (copy, nonatomic) NSString *type;
@property (copy, nonatomic) NSString *hd_audit_status;
@property (copy, nonatomic) NSString *hd_steps;
@property (copy, nonatomic) NSString *hd_reporting_status;

@property (copy, nonatomic) NSString *hd_category_id;//隐患类别
@property (copy, nonatomic) NSString *hd_category_name;//隐患类别
@property (copy, nonatomic) NSString *hd_level_id;//隐患等级
@property (copy, nonatomic) NSString *hd_rectification_type_id;//整改类型
@property (copy, nonatomic) NSString *hd_rectification_funds_id;//整改资金

//༥༤༽ཀབཀྲ་ཤིས་བདེ་ལེགས།
@property (copy, nonatomic) NSString *hd_acceptor_id;//验收人id
@property (copy, nonatomic) NSString *hd_acceptor_text;//验收人id

@property (copy, nonatomic) NSString *hd_acceptor_company_id;//隐患验收人单位id
@property (copy, nonatomic) NSString *hd_acceptor_company_text;//隐患验收人单位

@property (copy, nonatomic) NSString *hd_confirm_person_id;//确认人id
@property (copy, nonatomic) NSString *hd_confirm_person_text;//确认人

@property (copy, nonatomic) NSString *hd_confirm_department_id;//确认人部门id
@property (copy, nonatomic) NSString *hd_confirm_department_text;//确认人部门

@property (copy, nonatomic) NSString *hd_rectification_person_id;//隐患整改人id
@property (copy, nonatomic) NSString *hd_rectification_person_text;//隐患整改人中文

@property (copy, nonatomic) NSString *hd_rectification_company_id;//隐患整改人单位id
@property (copy, nonatomic) NSString *hd_rectification_company_text;//隐患整改人单位

//@property (copy, nonatomic) NSString *hd_confirm_department_person_id;// 确认部门人员id
//@property (copy, nonatomic) NSString *hd_confirm_department_person_text;//确认部门人员中文
//
//@property (copy, nonatomic) NSString *hd_confirm_department_company_id;// 确认部门人员部门id
//@property (copy, nonatomic) NSString *hd_confirm_department_company_text;//确认部门人员部门中文



@property (weak, nonatomic) IBOutlet UIView *view_two;
@property (weak, nonatomic) IBOutlet UIView *view_three;
@property (weak, nonatomic) IBOutlet UIView *view_one;
@property (weak, nonatomic) IBOutlet UIImageView *img_confirmThree;
@property (weak, nonatomic) IBOutlet UIImageView *img_invalidThree;
@property (weak, nonatomic) IBOutlet UIImageView *img_reportThree;

@property (weak, nonatomic) IBOutlet UILabel *lab_typeInvalid;//结存或作废

@property (weak, nonatomic) IBOutlet UILabel *lab_typeReport;

@property (copy, nonatomic) NSString *auditType;//1确认，2作废，3结存，4上报

@property (copy, nonatomic) NSString *textID;
@property (copy, nonatomic) NSString *text;
@property (copy, nonatomic) NSString *strID;
@property (copy, nonatomic) NSString *str;


@property (copy, nonatomic) NSString *peopleTextID;
@property (copy, nonatomic) NSString *peopleText;
@property (copy, nonatomic) NSString *peopleStrID;
@property (copy, nonatomic) NSString *peopleStr;

@property (weak, nonatomic) IBOutlet UIView *view_palyVioce;
@property (strong, nonatomic) SQPlayVoiceView * playVoiceView;

@end


@implementation SQConfirmConfirmViewController

- (void)viewDidLoad {
    self.tableViewInterface = self;
    [super viewDidLoad];
    self.navigationItem.title = @"隐患确认";
    
    self.view_confirm.hidden = NO;
 
    self.view_information.hidden = YES;

    self.hd_rectification_person_text = @"";
    self.hd_acceptor_text = @"";
    self.textID =  @"";
    self.text =  @"";
    
    self.strID = @"";;
    self.str = @"";;
    self.peopleTextID = @"";;
    self.peopleText = @"";;
    
    self.peopleStrID = @"";;
    self.peopleStr = @"";;
    
    self.view_one.hidden = YES;
    self.view_two.hidden = YES;
    self.view_three.hidden = YES;
   
    self.type = @"1";
    self.auditType = @"1";
    
    self.playVoiceView = [[SQPlayVoiceView alloc] init];
    
    [self.view_palyVioce addSubview:self.playVoiceView];
    
    [self getConfirmData];
 
    LC_WEAK_SELF
    
    self.cellRoller = ^(NSString * data, NSString * textID, NSString * text,NSString * strID, NSString * str) {
        
        if ([data isEqualToString:@"department"]) {
            [weakSelf.view endEditing:YES];
            weakSelf.textID = textID;
            weakSelf.text = text;
            
            weakSelf.strID = strID;
            weakSelf.str = str;
            
            
            
        }else if ([data isEqualToString:@"people"]) {
            [weakSelf.view endEditing:YES];
            weakSelf.peopleTextID = textID;
            weakSelf.peopleText = text;
            
            weakSelf.peopleStrID = strID;
            weakSelf.peopleStr = str;
        }

       

    };
}




-(void)getConfirmData{
    [SQQueryModel getDataWithParams:@{@"hd_id":self.hd_id} WithCallBack:^(SQQueryModel * data) {
        data.data.SQ_type = self.auditType;
        self.queryModel = data;
        if ( [MLevel isEqualToString:@"1"] ){//公司级别
            if ([data.data.hd_steps isEqualToString:@"4"]) {//如果hd_steps==4，显示确认，作废，结存，隐藏上报
                self.view_three.hidden =  NO;
                self.lab_typeInvalid.text = @"结存";
                self.lab_typeReport.text = @"作废";
            }else if ([data.data.hd_steps isEqualToString:@"3"]) {//如果hd_steps==3，隐藏上报，作废和结存，隐藏确认人部门和确认人，显示整改人和验收人，界面不可点击
                self.view_one.hidden =  NO;
                
            }else{
                self.view_three.hidden = NO;
                
            }

         }else if ( [MLevel isEqualToString:@"2"] ){//部门级
                if ([data.data.hd_reporting_status isEqualToString:@"1"]) {
                    /**如果hd_reporting_status==1，（公司到部门只有确认按钮）隐藏上报，作废，结存，整改人和验收人
                     否则的话显示确认，上报，作废，整改人和验收人，隐藏确认人部门和确认人*/
                    self.view_one.hidden =  NO;
                    
                    
                }else{
                    self.view_three.hidden = NO;
                }

             }else {
                  self.view_one.hidden = YES;
                  self.view_two.hidden = NO;
                  self.view_three.hidden = YES;
               }
            

        
        self.tf_area.text = data.data.site_area;
        self.tv_describe.text = data.data.hd_danger_description;
        self.tf_people.text = data.data.hd_report_person_text;
        self.tf_class.text = data.data.hd_confirm_team_person_text;
        self.tf_department.text = data.data.hd_confirm_department_person_text;
        self.tf_company.text = data.data.hd_confirm_company_person_text;
        self.tf_assessmentTime.text = [NSString formateDate:[data.data.hd_report_time substringWithRange:NSMakeRange(6,13)]];
        
        self.hd_reporting_status = data.data.hd_reporting_status;
        
                //隐患类别
        self.tf_type.text = data.data.hd_category_text;
        self.hd_category_id = data.data.hd_category_id;
                //隐患等级
        self.tf_level.text = data.data.hd_level_text;
        self.hd_level_id = data.data.hd_level_id;
                //隐患整改类型
        self.tf_rectificationType.text = data.data.hd_rectification_type_text;
        self.hd_rectification_type_id = data.data.hd_rectification_type_id;
                //计划完成时间
        self.tf_completionTime.text = data.data.hd_plan_complete;
                //整改资金
        self.tf_money.text = data.data.hd_rectification_funds_text;
        self.hd_rectification_funds_id = data.data.hd_rectification_funds_id;
        
        self.tf_prevention.text = data.data.hd_prevention_and_control_measures;
        self.tf_system.text = data.data.hd_list_of_system_measures;
        self.tf_rectification.text = data.data.hd_rectification_measures;

        [self.img_picOne setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",LC_ReqHeader,data.data.hd_report_pic_one]] placeholder:[UIImage imageNamed:@"addImage"]];
        
        [self.img_picTwo setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",LC_ReqHeader,data.data.hd_report_pic_two]] placeholder:[UIImage imageNamed:@"addImage"]];
        
        [self.img_picThree setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",LC_ReqHeader,data.data.hd_report_pic_three]] placeholder:[UIImage imageNamed:@"addImage"]];
        
        [self.playVoiceView buildPlayVoiceVie:data.data.hd_report_pic_audio];
        

        [SQGetDictionariesModel getDataWithParams:nil WithCallBack:^(SQGetDictionariesModel * data) {
            self.getDictionariesModel = data;
            }];
        
        
        self.tableView.tableHeaderView.height = W(494);
            
        
        [self reloadTableView];
    }];
}





//༥༤༽ཀབཀྲ་ཤིས་བདེ་ལེགས།

-(NSInteger)rowsCount:(NSInteger)section{
    if ([self.type isEqualToString:@"1"] || [self.type isEqualToString:@"3"]) {
        return 1;
    }
    return 0;
}

-(BaseModel *)modelForCell:(NSIndexPath *)indexPath{
    return  self.queryModel;
}




- (NSArray<NSArray<NSString *> *> *)classArr{
    return @[@[@"SQConfirmConfirmTableViewCell"]];
}

//༥༤༽ཀབཀྲ་ཤིས་བདེ་ལེགས།

/**隐患确认
*/
- (IBAction)clickConfirm:(UIButton *)sender {
    
    [self.view endEditing:YES];
    self.type = @"1";
    

    self.tableView.tableHeaderView.height = W(494);
    self.tableView.tableFooterView.height = W(270);
    self.tableView.tableFooterView.hidden = NO;

    
    [self.btn_confirm setTitleColor:[UIColor colorNamed:@"AccentColor"] forState:UIControlStateNormal];
    [self.btn_information setTitleColor:[UIColor colorNamed:@"333Color"] forState:UIControlStateNormal];
    self.view_confirm.hidden = NO;
    self.view_information.hidden = YES;
  
    dispatch_async(dispatch_get_main_queue(), ^{
            [self reloadTableView];
        });
    
}


/**隐患信息*/
- (IBAction)clickInformation:(UIButton *)sender {
    [self.view endEditing:YES];
    self.type = @"2";

    
    self.tableView.tableHeaderView.height = W(731);
    self.tableView.tableFooterView.height = W(0);
    self.tableView.tableFooterView.hidden = YES;
    
    [self.btn_information setTitleColor:[UIColor colorNamed:@"AccentColor"] forState:UIControlStateNormal];
    [self.btn_confirm setTitleColor:[UIColor colorNamed:@"333Color"] forState:UIControlStateNormal];
    self.view_confirm.hidden = YES;
    self.view_information.hidden = NO;
   
    dispatch_async(dispatch_get_main_queue(), ^{
            [self reloadTableView];
        });
    
    
}


/**审核状态 确认*/
- (IBAction)clickTypeConfirm:(UIButton *)sender {
    
    self.type = @"1";
    self.auditType = @"1";
    self.img_confirm.image = [UIImage imageNamed:@"green"];
    self.img_invalid.image = [UIImage imageNamed:@"grey"];
    self.queryModel.data.SQ_type = self.auditType;
    [self reloadTableView];
}


/**审核状态 作废*/
- (IBAction)clickTypeInvalid:(UIButton *)sender {
    
    self.type = @"2";
    self.auditType = @"3";
    self.hd_audit_status = @"5";
    self.img_confirm.image = [UIImage imageNamed:@"grey"];
    self.img_invalid.image = [UIImage imageNamed:@"red"];
    self.queryModel.data.SQ_type = self.auditType;
    [self reloadTableView];
}






/**审核状态 确认*/
- (IBAction)clickTypeConfirmThree:(UIButton *)sender {
    
    self.type = @"1";
    self.auditType = @"1";
    self.img_confirmThree.image = [UIImage imageNamed:@"green"];
    self.img_reportThree.image = [UIImage imageNamed:@"grey"];
    self.img_invalidThree.image = [UIImage imageNamed:@"grey"];
    self.queryModel.data.SQ_type = self.auditType;
    [self reloadTableView];
}

/**审核状态 上报*/
- (IBAction)clickTypeReportThree:(UIButton *)sender {
    
    self.auditType = @"2";
    
    if ( [MLevel isEqualToString:@"1"] ){//公司级别
        self.type = @"2";
        self.auditType = @"2";
       if ([self.queryModel.data.hd_steps isEqualToString:@"4"]) {//如果hd_steps==4，显示确认，作废，结存，隐藏上报
           
           self.img_reportThree.image = [UIImage imageNamed:@"red"];
           
       }
        
    }else{
        self.type = @"3";
        self.auditType = @"4";
        self.img_reportThree.image = [UIImage imageNamed:@"green"];
    }
    
    self.img_confirmThree.image = [UIImage imageNamed:@"grey"];
    self.img_invalidThree.image = [UIImage imageNamed:@"grey"];
    self.queryModel.data.SQ_type = self.auditType;
    [self reloadTableView];
}


/**审核状态 作废*/
- (IBAction)clickTypeInvalidThree:(UIButton *)sender {
    
    self.type = @"2";
  
    self.hd_audit_status = @"5";
    if ( [MLevel isEqualToString:@"1"] ){//公司级别
       if ([self.queryModel.data.hd_steps isEqualToString:@"4"]) {//如果hd_steps==4，显示确认，作废，结存，隐藏上报
           self.auditType = @"3";
           self.img_invalidThree.image = [UIImage imageNamed:@"green"];
       }
        
    }else{
        self.auditType = @"2";
        self.img_invalidThree.image = [UIImage imageNamed:@"red"];
    }
    
    self.img_confirmThree.image = [UIImage imageNamed:@"grey"];
    self.img_reportThree.image = [UIImage imageNamed:@"grey"];
    
    self.queryModel.data.SQ_type = self.auditType;
    [self reloadTableView];
}



/**隐患类型*/
- (IBAction)clickType:(UIButton *)sender {
    [self.view endEditing:YES];
    if (self.getDictionariesModel == nil) {return;}
    
    self.getDictionariesModel.hd_categoryArr.pickerSigleShow(self.tf_type,@"隐患类别").finish = ^(UITextField * textField){
        SQGetDictionariesModelHd_category *hd_categoryArr  = self.getDictionariesModel.hd_category[self.tf_type.selectIndex[0].intValue];
        self.hd_category_id = hd_categoryArr.d_id;
        
    };
    
}

/**隐患等级*/
- (IBAction)clickLevel:(UIButton *)sender {
    [self.view endEditing:YES];
    if (self.getDictionariesModel == nil) {return;}
    

    self.getDictionariesModel.hd_levelArr.pickerSigleShow(self.tf_level,@"隐患等级").finish = ^(UITextField * textField){
        SQGetDictionariesModelHd_level *hd_level  = self.getDictionariesModel.hd_level[self.tf_level.selectIndex[0].intValue];
        self.hd_level_id = hd_level.d_id;
        
    };
    
}

/**隐患整改类型*/
- (IBAction)clickRectification:(UIButton *)sender {
    [self.view endEditing:YES];
    if (self.getDictionariesModel == nil) {return;}
    
    self.getDictionariesModel.hd_rectification_typeArr.pickerSigleShow(self.tf_rectificationType,@"隐患整改类型").finish = ^(UITextField * textField){
        SQGetDictionariesModelHd_rectification_type *rectification_type  = self.getDictionariesModel.hd_rectification_type[self.tf_rectificationType.selectIndex[0].intValue];
        self.hd_rectification_type_id = rectification_type.d_id;
        

        
    };
}

/**计划时间*/
- (IBAction)clickTime:(UIButton *)sender {
    [self.view endEditing:YES];
    HRBDateSelectView.showForType(HRBDateSelectTypeAfter_YMD).formatString(HRBTimeFormat_YMD).result = ^(NSString * _Nonnull time, NSDate * _Nonnull date) {
        
        self.tf_completionTime.text = time;
    };
   
}


/**整改资金*/
- (IBAction)clcikMoney:(UIButton *)sender {
    [self.view endEditing:YES];
    if (self.getDictionariesModel == nil) {return;}
    
    self.getDictionariesModel.hd_rectification_fundsArr.pickerSigleShow(self.tf_money,@"整改资金").finish = ^(UITextField * textField){
        SQGetDictionariesModelHd_rectification_funds *rectification_funds  = self.getDictionariesModel.hd_rectification_funds[self.tf_money.selectIndex[0].intValue];
        self.hd_rectification_funds_id = rectification_funds.d_id;
        
       
    };
    
}



/**确认*/
- (IBAction)clickSubmit:(UIButton *)sender {
    [self.view endEditing:YES];
   
        if ([MLevel isEqualToString:@"1"]){//公司级别
            
                if ([self.auditType isEqualToString:@"1"]){//1确认，2作废，3结存，4上报
                    
                        if ([self.queryModel.data.hd_steps isEqualToString:@"4"]) {
                          
                            
                            self.hd_audit_status = @"0";
                            self.hd_steps = @"2";
                        SQ_LOG(@"%@ - %@ - %@ - %@ - %@ - %@ - %@ - %@",self.textID,self.text,self.peopleStrID,self.peopleStr,self.strID,self.str,self.peopleTextID,self.peopleText);


                        self.hd_confirm_department_id = self.textID;
                        self.hd_confirm_department_text = self.text;

                        self.hd_confirm_person_id = self.peopleTextID;
                        self.hd_confirm_person_text = self.peopleText;

                        if([self.hd_confirm_department_id isEqualToString:@""]){

                            [CCToast showMessage:@"请选择部门"];
                            return;
                        }else if([self.hd_confirm_person_id isEqualToString:@""]){

                            [CCToast showMessage:@"请选择确认人"];
                            return;
                        }
                        
                        }else if([self.queryModel.data.hd_steps isEqualToString:@"3"]){
                            //如果hd_steps==3，隐藏上报，作废和结存，隐藏确认人部门和确认人，显示整改人和验收人，界面不可点击
                            self.hd_audit_status = @"";
                            self.hd_steps = @"5";
                        }

                   
               
                    
                    if([self.tv_note.text isEqualToString:@""]){
                       
                        [CCToast showMessage:@"请填写备注说明"];
                        return ;
                    }
//
                        
                    [self upLoadData];
                        
                    
                }else if ([self.auditType isEqualToString:@"2"]){//1确认，2作废，3结存，4上报
                    
                    self.hd_steps = @"5";
                    self.hd_audit_status = @"5";
                    if([self.tv_note.text isEqualToString:@""]){
                       
                        [CCToast showMessage:@"请填写备注说明"];
                        return ;
                    }
                    [self upLoadData];
                    
                }
//                else if ([self.auditType isEqualToString:@"3"]){//1确认，2作废，3结存，4上报
//                    self.hd_steps = @"4";
//                    self.hd_audit_status = @"4";
//                    [self upLoadData];
//                }

           
            
        }else if ( [MLevel isEqualToString:@"2"] ){//部门级别

        if ([self.auditType isEqualToString:@"1"]) {//1确认，2作废，3结存，4上报

            self.hd_rectification_person_id = self.textID;
            self.hd_rectification_person_text = self.text;
            
            self.hd_rectification_company_id = self.strID;
            self.hd_rectification_company_text = self.str;
            
            self.hd_acceptor_id = self.peopleTextID;
            self.hd_acceptor_text = self.peopleText;
            
            self.hd_acceptor_company_id = self.peopleStrID;
            self.hd_acceptor_company_text = self.peopleStr;
            
            self.hd_confirm_department_id = MOne;
            self.hd_confirm_department_text = MOneText;
            
            SQ_LOG(@"%@ - %@ - %@ - %@ - %@ - %@ - %@ - %@",self.textID,self.text,self.peopleStrID,self.peopleStr,self.strID,self.str,self.peopleTextID,self.peopleText);
            
            
            self.hd_audit_status = @"1";
            self.hd_steps = @"3";
            if ([self verification]) {
                [self upLoadData];
            }
        }else if ([self.auditType isEqualToString:@"2"]){//1确认，2作废，3结存，4上报
            self.hd_audit_status = @"5";
            self.hd_steps = @"3";
            
            if([self.tv_note.text isEqualToString:@""]){
               
                [CCToast showMessage:@"请填写备注说明"];
                return ;
            }
            [self upLoadData];
            
        }else if ([self.auditType isEqualToString:@"4"]){//1确认，2作废，3结存，4上报
        
            self.hd_confirm_person_id =self.peopleStrID;
            self.hd_confirm_person_text =self.peopleStr;
            
            self.hd_confirm_department_id = MOne;
            self.hd_confirm_department_text = MOneText;
            
            
            SQ_LOG(@"%@ - %@ - %@ - %@",self.hd_confirm_department_id,self.hd_confirm_department_text,self.peopleStrID,self.peopleStr);
            
            self.hd_steps = @"4";
            self.hd_reporting_status = @"1";
            self.hd_audit_status = @"0";
           if([self.hd_confirm_department_text isEqualToString:@""]){
               
                [CCToast showMessage:@"请选择部门"];
                return;
            }else if([self.hd_confirm_person_text isEqualToString:@""]){
               
                [CCToast showMessage:@"请选择确认人"];
                return;
            }else if([self.tv_note.text isEqualToString:@""]){
                
                [CCToast showMessage:@"请填写备注说明"];
                return ;
            }
            [self upLoadData];
        }
    } else if ([MLevel isEqualToString:@"3"]){//班组级别
        
        self.hd_steps = @"2";
        self.hd_audit_status = @"0";
        
        if ([self.auditType isEqualToString:@"1"]) {//1确认，2作废，3结存，4上报
            self.hd_confirm_person_id = self.peopleTextID;
            self.hd_confirm_person_text =  self.peopleText;
            
            self.hd_confirm_department_id = self.textID;
            self.hd_confirm_department_text = self.text;
            
            SQ_LOG(@"%@ - %@ - %@ - %@ - %@ - %@ - %@ - %@",self.textID,self.text,self.peopleStrID,self.peopleStr,self.strID,self.str,self.peopleTextID,self.peopleText);
            
            if([self.hd_confirm_department_text isEqualToString:@""]){
               
                [CCToast showMessage:@"请选择部门"];
                return;
               
            }else if([self.hd_confirm_person_text isEqualToString:@""]){
               
                [CCToast showMessage:@"请选择确认人"];
                return;
               
            }else{
                
                [self upLoadData];
                
            }

        }else{
            
            self.hd_audit_status = @"5";
            
             self.hd_steps = @"2";
            
            if([self.tv_note.text isEqualToString:@""]){
               
                [CCToast showMessage:@"请填写备注说明"];
                return ;
            }
            [self upLoadData];
        }

    }
    
}



-(void)upLoadData{
    
    /**法用途：隐患确认操作。传参：
     隐患id(hd_id),
     当前登录人层级(m_level),
     当前登陆人id(m_id),
     当前登陆人中文(m_name),
     当前登陆人部门id(m_group),
     当前登陆人部门中文(m_number),
     选择隐患确认人id(hd_confirm_person_id),
     选择隐患确认人中文(hd_confirm_person_text),
     选择隐患确认部门id(hd_confirm_department_id),
     选择隐患确认部门中文(hd_confirm_department_text),
     隐患确认备注(hd_confirm_count),
     隐患类别id(hd_category_id),
     隐患类别中文(hd_category_text),
     隐患等级id(hd_level_id),
     隐患等级中文(hd_level_text),
     隐患整改类型id(hd_rectification_type_id),
     隐患整改类型中文(hd_rectification_type_text),
     计划完成时间(hd_plan_complete),
     整改资金(hd_rectification_funds_id),
     整改资金中文(hd_rectification_funds_text),
     防控措施(hd_prevention_and_control_measures),
     整改措施(hd_rectification_measures),
     制度措施清单(hd_list_of_system_measures),
     审核状态(hd_audit_status),
     隐患步骤(hd_steps),0正常班组到部门、部门到部门 1公司到部门只有确认按钮(hd_reporting_status),
     隐患整改人id(hd_rectification_person_id),
     隐患整改人中文(hd_rectification_person_text),
     隐患整改人单位id(hd_rectification_company_id),
     隐患整改人单位中文(hd_rectification_company_text),
     隐患验收人id(hd_acceptor_id),
     隐患验收人中文(hd_acceptor_text),
     隐患验收人单位id(hd_acceptor_company_id),
     隐患验收人单位中文(hd_acceptor_company_text)。
     成功回参：code：200|隐患增加后返回的id。失败回参：code：0|msg。*/

    [SQConfirmConfirmModel getDataWithParams:@{
        @"hd_id":self.hd_id,
        @"m_level":MLevel,
        @"m_id":UID,
        @"m_name":MName,
        @"m_group":MGroup,
        @"m_number":MNumber,
    
        @"hd_confirm_count":self.tv_note.text?self.tv_note.text:@"",
        
        @"hd_category_id":self.hd_category_id?self.hd_category_id:@"0",
        @"hd_category_text":self.tf_type.text?self.tf_type.text:@"",
        
        @"hd_level_id":self.hd_level_id?self.hd_level_id:@"0",
        @"hd_level_text":self.tf_level.text?self.tf_level.text:@"",
    
        @"hd_rectification_type_id":self.hd_rectification_type_id?self.hd_rectification_type_id:@"0",
        @"hd_rectification_type_text": self.tf_rectificationType.text? self.tf_rectificationType.text:@"",
        
        @"hd_plan_complete":self.tf_completionTime.text?self.tf_completionTime.text:@"",
        
        @"hd_rectification_funds_id":self.hd_rectification_funds_id?self.hd_rectification_funds_id:@"0",
        @"hd_rectification_funds_text":self.tf_money.text?self.tf_money.text:@"",
        
        @"hd_prevention_and_control_measures":self.tf_prevention.text?self.tf_prevention.text:@"",
        @"hd_rectification_measures":self.tf_rectification.text?self.tf_rectification.text:@"",
        @"hd_list_of_system_measures":self.tf_system.text?self.tf_system.text:@"",
        
        @"hd_audit_status":self.hd_audit_status,
        @"hd_steps":self.hd_steps,
        @"hd_reporting_status":self.hd_reporting_status,
        
        
        @"hd_confirm_person_id":self.hd_confirm_person_id?self.hd_confirm_person_id:@"0",//确认人员id
        @"hd_confirm_person_text":self.hd_confirm_person_text?self.hd_confirm_person_text:@"",//确认人员zhonw
        
        @"hd_confirm_department_id":self.hd_confirm_department_id?self.hd_confirm_department_id:@"0",//确认部门id
        @"hd_confirm_department_text":self.hd_confirm_department_text?self.hd_confirm_department_text:@"",//确认部门中文
        

        @"hd_rectification_person_id":self.hd_rectification_person_id?self.hd_rectification_person_id:@"0",//隐患整改人id
        @"hd_rectification_person_text":self.hd_rectification_person_text?self.hd_rectification_person_text:@"",//隐患整改人中文
        @"hd_rectification_company_id":self.hd_rectification_company_id?self.hd_rectification_company_id:@"0",//隐患整改人单位id
        @"hd_rectification_company_text":self.hd_rectification_company_text?self.hd_rectification_company_text:@"",//隐患整改人单位中文
        
        @"hd_acceptor_id":self.hd_acceptor_id?self.hd_acceptor_id:@"0",// 隐患验收人id
        @"hd_acceptor_text":self.hd_acceptor_text?self.hd_acceptor_text:@"",//隐患验收人中文
        @"hd_acceptor_company_id":self.hd_acceptor_company_id?self.hd_acceptor_company_id:@"0",//隐患验收人单位id
        @"hd_acceptor_company_text":self.hd_acceptor_company_text?self.hd_acceptor_company_text:@"",//隐患验收人单位中文


                 
    } WithCallBack:^(SQConfirmConfirmModel * data) {
        
        [CCToast showMessage:data.msg];
        
        [[NSNotificationCenter defaultCenter] postNotificationName:@"confirm" object:nil];
        [self.navigationController popViewControllerAnimated:YES];
        
    }];
    
}


#pragma mark ---- 验证
- (BOOL)verification {
    BOOL ret = NO;
    if([self.tf_type.text isEqualToString:@""]){
       
        [CCToast showMessage:@"请选择隐患类型"];
        return NO;
    }
    
    
    if([self.tf_level.text isEqualToString:@""]){
       
        [CCToast showMessage:@"请选择隐患等级"];
        return NO;
    }
    if([self.tf_rectificationType.text isEqualToString:@""]){
       
        [CCToast showMessage:@"请选择隐患整改类型"];
        return NO;
    }
   
    if([self.tf_completionTime.text isEqualToString:@""]){
       
        [CCToast showMessage:@"请选择计划完成时间"];
        return NO;
    }
    
   
    
    if([self.tf_money.text isEqualToString:@""]){
       
        [CCToast showMessage:@"请选择整改资金"];
        return NO;
    }
    if([self.tf_prevention.text isEqualToString:@""]){
       
        [CCToast showMessage:@"请输入防控措施"];
        return NO;
    }
    if([self.tf_system.text isEqualToString:@""]){
       
        [CCToast showMessage:@"请输入制度措施清单"];
        return NO;
    }
    
    if([self.tf_rectification.text isEqualToString:@""]){
       
        [CCToast showMessage:@"请输入整改措施"];
        return NO;
    }
    
    if([self.tf_rectification.text isEqualToString:@""]){
       
        [CCToast showMessage:@"请输入整改措施"];
        return NO;
    }
    
 
        if([self.hd_rectification_person_text isEqualToString:@""]){
           
            [CCToast showMessage:@"请选择整改人"];
            return NO;
           
        }
        if([self.hd_acceptor_text isEqualToString:@""]){
           
            [CCToast showMessage:@"请选择验收人"];
            return NO;
           
        }
    if([self.tv_note.text isEqualToString:@""]){
       
        [CCToast showMessage:@"请输入备注说明"];
        return NO;
       
    }else{
        ret = YES;
    }
    return YES;
}


#pragma mark -- 图片放大

- (IBAction)clickShowImage:(UIButton *)sender {

    if (sender.tag == 10) {
        [SQShowImage showImage:self.img_picOne];
    }else if (sender.tag == 20){
        [SQShowImage showImage:self.img_picTwo];
    }else if (sender.tag == 30){
        [SQShowImage showImage:self.img_picThree];
    }
}


@end
